package md.mru.backend.core.domains.administration;

import md.mru.backend.core.domains.Folder;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author sergiu.marin
 * @since 14.04.2014.
 */
@Entity
@Table(name = "tree_node_models", schema = "c##mru_optimized")
public class TreeNodeModel implements Serializable {

    private static final long serialVersionUID = 7480582709796744431L;

    @Id
    @Column(name = "id", unique = true, nullable = false, precision = 10, scale = 0)
    @GeneratedValue(generator = "tm_sequence")
    @SequenceGenerator(name = "tm_sequence", sequenceName = "tree_node_model_sequence", allocationSize = 1)
    private long id;

    //@ManyToOne(fetch = FetchType.LAZY, )
    @JoinColumn(name = "pid", table = "tree_node_model", referencedColumnName = "id")
    @Column(name = "pid")
    private long parentId;

    private String name;

    private String description;

    @Column(name = "position", columnDefinition = "BINARY_DOUBLE")
    private double position;

    @ManyToOne
    @JoinColumn(name = "fnc_classification_id")
    private FunctionClassification functionClassification;     // tre.tre_tpe - nml_fnc

    @ManyToMany
    @JoinTable(name = "tree_user_groups", joinColumns = @JoinColumn(name = "tree_id"), inverseJoinColumns = @JoinColumn(name = "group_id"))
    private List<UserGroup> groups;

    /*@ManyToMany
    @JoinTable(name = "tree_folders", joinColumns = @JoinColumn(name = "tree_id"), inverseJoinColumns = @JoinColumn(name = "folder_id"))
    private List<Folder> folders;*/

    /*@OneToMany(fetch = FetchType.LAZY, mappedBy = "id.treeNodeModel", cascade = CascadeType.PERSIST)
    private List<TreeModelFolder> treeModelFolders;*/

    @Column(name = "phone_no_1")
    private String phoneNo1;

    @Column(name = "phone_no_2")
    private String phoneNo2;

    @Column(name = "phone_no_3")
    private String phoneNo3;

    @Column(name = "validate_from")
    private Date validateFrom;

    @Column(name = "validate_to")
    private Date validateTo;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getParentId() {
        return parentId;
    }

    public void setParentId(long parentId) {
        this.parentId = parentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String nme) {
        this.name = nme;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String dsc) {
        this.description = dsc;
    }

    public Double getPosition() {
        return position;
    }

    public void setPosition(Double fvr) {
        this.position = fvr;
    }

    public FunctionClassification getFunctionClassification() {
        return functionClassification;
    }

    public void setFunctionClassification(FunctionClassification functionClassification) {
        this.functionClassification = functionClassification;
    }

    public List<UserGroup> getGroups() {
        return groups;
    }

    public void setGroups(List<UserGroup> groups) {
        this.groups = groups;
    }

    public String getPhoneNo1() {
        return phoneNo1;
    }

    public void setPhoneNo1(String tel1) {
        this.phoneNo1 = tel1;
    }

    public String getPhoneNo2() {
        return phoneNo2;
    }

    public void setPhoneNo2(String tel2) {
        this.phoneNo2 = tel2;
    }

    public String getPhoneNo3() {
        return phoneNo3;
    }

    public void setPhoneNo3(String tel3) {
        this.phoneNo3 = tel3;
    }

    public Date getValidateFrom() {
        return validateFrom;
    }

    public void setValidateFrom(Date vldFrm) {
        this.validateFrom = vldFrm;
    }

    public Date getValidateTo() {
        return validateTo;
    }

    public void setValidateTo(Date vldTo) {
        this.validateTo = vldTo;
    }

    /*public List<TreeModelFolder> getTreeModelFolders() {
        return treeModelFolders;
    }

    public void setTreeModelFolders(List<TreeModelFolder> treeModelFolders) {
        this.treeModelFolders = treeModelFolders;
    }*/
}
